package com.laihui.fragment;


import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.view.View;
import android.widget.LinearLayout;

import com.laihui.MyApplication;
import com.laihui.activity.CompanyProfileActivity;
import com.laihui.activity.R;


import com.laihui.activity.PlatformAnnouncementActivity;
import com.laihui.base.BaseFragment;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 我的投资页面
 */
public class Index4Fragment extends BaseFragment {

    @BindView(R.id.ll_activity)
    LinearLayout ll_activity;
    @BindView(R.id.ll_news)
    LinearLayout ll_news;
    @BindView(R.id.ll_about)
    LinearLayout ll_about;

    private Activity mActivity;
    private MyApplication application;

    private BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals("android.action.user.exit")) {
              //  exit();
            } else if (intent.getAction().equals("android.action.toWithDraw")) {

            } else if (intent.getAction().equals("android.action.refresh")) {
                loadData();

                //getHotSale(true);
            }
        }
    };





    @Override
    public void init() {
        mActivity = getActivity();
        application = (MyApplication) mActivity.getApplication();
        loadData();

    }
    public void loadData(){

    }

    @Override
    public void onResume() {
        super.onResume();
        IntentFilter filter = new IntentFilter();
        filter.addAction("android.action.user.exit");
        filter.addAction("android.action.toWithDraw");
        filter.addAction("android.action.refresh");
        mActivity.registerReceiver(receiver, filter);
        refresh();
    }
    public void refresh(){
        loadData();
    }


    @Override
    public int getFragmentId() {
        return R.layout.fragment_index4;

    }

    @Override
    public Object bindFragment() {
        return this;

    }
    @OnClick({R.id.ll_about,R.id.ll_news,R.id.ll_activity})
    public void onViewClicked(View view) {
        Intent intent =  new Intent(mActivity, PlatformAnnouncementActivity.class);

        switch (view.getId()) {
            case R.id.ll_news://充值

            intent.putExtra("cate_name","intro");
                startActivity(intent);
            break;

            case R.id.ll_about:

                startActivity(new Intent(getActivity(), CompanyProfileActivity.class));
                break;


            case R.id.ll_activity:

                intent.putExtra("cate_name","activity");
                startActivity(intent);
                break;



        }

    }
}
